#include<iostream>
#include<vector>
#include<set>
#include<utility>
using namespace std;

void test1()
{
    // vector<int> v={1,2,3,4,5};
    // set<int> myset(v.begin(),v.end());

    set<int> myset = {1, 2, 3, 4, 5};
    for (auto e : myset)
    {
        cout << e << " ";
    }
    cout << endl;
}

void test2()
{
    set<int> myset = {1, 2, 3, 4, 5};
    set<int>::iterator it = myset.begin();
    while (it != myset.end())
    {
        //(*it)++;
        cout << *it << " ";
        ++it;
    }
    cout << endl;

    set<int>::reverse_iterator rit = myset.rbegin();
    while (rit != myset.rend())
    {
        cout << *rit << " ";
        ++rit;
    }
    cout << endl;
}

void test3()
{
    set<int> myset = {1, 2, 3, 4, 5};
    pair<set<int>::iterator, bool> it1 = myset.insert(100);
    pair<set<int>::iterator, bool> it2 = myset.insert(2);
    cout << it1.second << " " << it2.second << endl;

    vector<int> v = {10, 20, 30, 40, 50};
    myset.insert(v.begin(), v.end());

    for (auto e : myset)
    {
        cout << e << " ";
    }
    cout << endl;
}

void test4(){
    set<int> myset={1,2,3,4,5,6,7,9,10};
    myset.erase(7);
    for(auto e:myset){
        cout<<e<<" ";
    }
    cout<<endl;

    set<int>::iterator it1=myset.lower_bound(2);
    set<int>::iterator it2=myset.upper_bound(5);
    myset.erase(it1,it2);
    for(auto e:myset){
        cout<<e<<" ";
    }
    cout<<endl;
}

void test5()
{
    set<int> myset = {1, 2, 3, 4, 5, 6};
    cout << myset.size() << endl;
    cout << myset.empty() << endl;
}

void test6()
{
    set<int> myset = {5, 6, 4, 2, 3, 7, 1, 8, 0, 9};
    set<int>::iterator it1 = myset.find(7);
    while (it1 != myset.end())
    {
        cout << *it1 << " ";
        ++it1;
    }
    cout << endl;

    set<int>::iterator it2 = myset.lower_bound(2);
    set<int>::iterator it3 = myset.upper_bound(6);
    cout << *it2 << " " << *it3 << endl;
    while (it2 != it3)
    {
        cout << *it2 << " ";
        it2++;
    }
    cout << endl;
}

void test7(){
    multiset<int> myset = {4,2,6,1,2,3,5,2,1,7};
    size_t i=myset.count(2);
    cout<<i<<endl;

    pair<multiset<int>::iterator,multiset<int>::iterator> ipair=myset.equal_range(2);
    myset.erase(ipair.first,ipair.second);
    for(auto e : myset){
        cout<<e<<" ";
    }
    cout<<endl;

}

int main()
{
    // test1();                       //初始化测试函数
    // test2();                       //访问元素测试函数
    // test3();                       //插入元素测试
    //test4();                        // 删除函数测试
    // test5();                       //容量大小
    // test6();                       //查找函数测试
    test7();
    return 0;
}